﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VMDS.Business.Entities;
using VMDS.Data.SQL;

namespace VMDS.Data
{
    public class OsSqlAdapter:ICrudEntity<OS>
    {
        private ModelContainer _db;
        public ICollection<OS> GetAll()
        {
            return new List<OS>(_db.OSs);
        }

        public OS GetById(int id)
        {
            return _db.OSs.SingleOrDefault(x => x.Id == id);
        }

        public void Update(OS obj)
        {
            var old = GetById(obj.Id);
            old.Name = obj.Name;
            old.Version = obj.Version;
            //old.Storages = obj.Storages;

        }

        public void Delete(OS obj)
        {
            var old = GetById(obj.Id);
            _db.OSs.DeleteObject(old);
        }

        public void Create(OS obj)
        {
            var old = _db.OSs.CreateObject();
            old.Name = obj.Name;
            old.Version = obj.Version;
          //  old.Storages = obj.Storages;
        }
        public OsSqlAdapter(ModelContainer db)
        {
            _db = db;
        }
    }
}
